package com.chuantou.yuba.ui.fragment;

import java.text.DecimalFormat;
import java.util.Map;

import com.chuantou.yuba.pojo.Pageable;

public abstract class NearFilterFragment<T extends Pageable> extends PaginationListFragment<T> {

	public void filter(String key, String value) {
		filter(key, value, true);
	}

	public void filter(String key, String value, boolean request) {
		clearAll();
		Map<String, String> params = mRequest.getParams();
		if (params != null) {
			params.put(key, value);
		}
		if (request) {
			load(1);
		}
	}

	protected String formatDistance(double distance) {
		DecimalFormat format = new DecimalFormat();
		format.setMaximumFractionDigits(2);
		format.setMinimumFractionDigits(0);
		return format.format(distance);
	}

	protected abstract void clearAll();
}
